
  import BScroll from '@better-scroll/core'
  import Pullup from '@better-scroll/pull-up'
  import { Rate } from 'vant'
  import headss from '../../components/header/index.vue'
  import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
  BScroll.use(Pullup)

  export default {
    data() {
      return {
        isPullUpLoad: false,
        data: 30,
        value:2,
        head:false,
        Nueselist:[{
          id:1,
          img:"https://lanhu.oss-cn-beijing.aliyuncs.com/pss5smk6zewqh04am7x50ulo58k0do82lo7bb39fbe-90b8-4afe-bd52-a6c9b2dabb5e"
        },{
          id:2,
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/pskk5afj8usha6qln1wzy646rqptqx625ws32512a6c-5065-42f4-81f4-bb9d3995e2ed'
        },{
          id:4,
          img:"https://lanhu.oss-cn-beijing.aliyuncs.com/pss5smk6zewqh04am7x50ulo58k0do82lo7bb39fbe-90b8-4afe-bd52-a6c9b2dabb5e"
        },{
          id:5,
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/pskk5afj8usha6qln1wzy646rqptqx625ws32512a6c-5065-42f4-81f4-bb9d3995e2ed'
        },{
          id:6,
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/psn9e7qc90jjp3zpb2a99n4jg9kd4hxv74ea226e2-f080-49e1-a307-b12827f17695'
        }],
        list:[{
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/pskyp9sucyuv030q2yh2bkki51u2oh18c2w1a2ce083-c991-4004-8f82-853be4903147',
          name:'开心宝宝每一天',
          value:'4',
          data:"3天前",
          info:"第一次来这家店，店员小姐姐服务非常受到，非常耐心指导，泡芙一点也没闹，下次还会来这里的。"
        },{
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/ps49hxolz78asrmakzozepoonh7tkpwjrkbdd7027b6-3fbe-4bcb-a0d0-e25b51a7773e',
          name:'哈利波特',
          value:'4',
          data:"2021-05-21",
          info:"环境好，服务好，没有异味，价格合理，必须好评。"
        },{
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/psarrf62epnxtz2xp3pdjc3r29ksy92nir6ffe9039-5d55-44ca-aabe-a9f31ad4deb4',
          name:'王泡芙',
          value:'4',
          data:"2021-05-21",
          info:"这家店的老客户了，家里的泡芙一直来这家店。"
        },{
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/psaj1ycjhof96nw90kzrsypbj0g2qtt23c165410b-d6eb-472b-9443-9f1c01110dae',
          name:'babe',
          value:'4',
          data:"3天前",
          info:"非常满意，这里的医师都很专业，超级好，非常耐心而且问任何问题都耐心解答。"
        }],
        swiperOptions: {
          slidesPerView: 'auto',
          // centeredSlides: true,
          touchMoveStopPropagation :true,
          // spaceBetween: 10,
          pagination: {
            el: '.swiper-pagination',
            clickable: true
          }
        },
      }
    },
    components: {
      headss,
      Swiper,
      SwiperSlide,
      [Rate.name]: Rate,
    },
    mounted() {
      this.initBscroll()
    },
    methods: {
      goto(){
        this.$router.go(-1)
      },
      initBscroll() {
        this.bscroll = new BScroll(this.$refs.scroll, {
          pullUpLoad: true,
          probeType:3,
        })
        this.bscroll.on('scroll', (y) => {   
          console.log(y.y,'弟弟')  
          this.$refs.headtop.back(y.y)   
          if(y.y<-100){
          } else {
            this.$refs.headtop.back(y.y)
          }
        })
        this.bscroll.on('pullingUp', this.pullingUpHandler)
      },
      async pullingUpHandler() {
        console.log('我到底了')
        this.isPullUpLoad = true   
        await this.requestData()
        console.log(this.list,'我服了')      
        this.bscroll.finishPullUp()
        this.bscroll.refresh()  
        this.isPullUpLoad = false         
      },
      async requestData() {
        try {
          const newData = await this.ajaxGet(/* url */)
          this.list.push(...newData)           
        } catch (err) {
          // handle err
          console.log(err)
        }
      },
      ajaxGet(/* url */) {
       
        return new Promise(resolve => {
          setTimeout(() => {
            resolve([{
              img:'https://lanhu.oss-cn-beijing.aliyuncs.com/pskyp9sucyuv030q2yh2bkki51u2oh18c2w1a2ce083-c991-4004-8f82-853be4903147',
              name:'开心宝宝每一天',
              value:'1',
              data:"3天前",
              info:"第一次来这家店，店员小姐姐服务非常受到，非常耐心指导，泡芙一点也没闹，下次还会来这里的。"
            },{
              img:'https://lanhu.oss-cn-beijing.aliyuncs.com/ps49hxolz78asrmakzozepoonh7tkpwjrkbdd7027b6-3fbe-4bcb-a0d0-e25b51a7773e',
              name:'哈利波特',
              value:'2',
              data:"2021-05-21",
              info:"环境好，服务好，没有异味，价格合理，必须好评。"
            },{
              img:'https://lanhu.oss-cn-beijing.aliyuncs.com/psarrf62epnxtz2xp3pdjc3r29ksy92nir6ffe9039-5d55-44ca-aabe-a9f31ad4deb4',
              name:'王泡芙',
              value:'3',
              data:"2021-05-21",
              info:"这家店的老客户了，家里的泡芙一直来这家店。"
            },{
              img:'https://lanhu.oss-cn-beijing.aliyuncs.com/psaj1ycjhof96nw90kzrsypbj0g2qtt23c165410b-d6eb-472b-9443-9f1c01110dae',
              name:'babe',
              value:'5',
              data:"3天前",
              info:"非常满意，这里的医师都很专业，超级好，非常耐心而且问任何问题都耐心解答。"
            }])
          },1000)
        })
      }
    }
  }